package com.wanrue.tcc.admin.util;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class Page<T> {

    private int pages = 0;

    private int total = 0;

    private int size = 10;

    private int current = 1;

    private Map<String, Object> param;

    private List<T> records = Collections.emptyList();

    Page() {
    }

    public int getPages() {
        this.pages = (total % size == 0) ? (total / size) : (total / size) + 1;
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getCursor() {
        return size * ((current - 1 >= 0) ? (current - 1) : 0);
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public Map<String, Object> getParam() {
        return param;
    }

    public void setParam(Map<String, Object> param) {
        this.param = param;
    }
}
